Repository navigation
fix: add export-surface check, C#/JVM syntax check in gen and verify, candidate CHANGELOG - #691
Merged
Merged
Conversation
…NGELOG in candidates Record the export-surface baselines from the 1.3.0 registries (the recorder now installs each package's peers), move the new entries to changelog.d fragments now that 1.3.0 is released, keep codegen-kotlin's 1.9.24 parser off the kctfork test classpaths, write the JVM syntax error on one line and typecheck the new scripts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
scripts/check-export-surface.mjs, with per-port listers for TypeScript, JVM, C# and Python underscripts/export-surface/and committed baselines of each port's public surface. It is wired intoscripts/ci-local.sh. A public name removed since the last release that is not named in the CHANGELOG upgrade list now fails the candidate build.record-published.mjsrecords the baseline, andscripts/test-check-export-surface.mjstests the check.genandverifyfor C#, Java and Kotlin. This matches what TypeScript and Python already do.EmittedCSharpCheckruns fromCodegenRunner.JavaSyntaxCheckruns fromGeneratedFileWriterthrough a newGeneratedSyntaxCheckhook.KotlinSyntaxCheckis registered as a service provider incodegen-kotlin.generateandverifymojos call the check, and tests cover each port.scripts/prerelease.mjsandscripts/prerelease-version.mjsnow ship the CHANGELOG with each pre-release candidate, so adopters read the notes that match the candidate they test.CONTRIBUTING.md,docs/RELEASING.md,docs/features/prerelease.mdandtools/prerelease/estate-run.mddocument the export-surface check and the candidate changelog.CONTRIBUTING.mdalso adds a review rule: when a deliberate break makes a compatibility test obsolete, change the test to expect the clear failure plus the upgrade note. Never delete it.changelog.dentries record the changes.The two build breaks adding the JVM parse check caused
Neither was a defect in generated code that the new check caught. Both were breaks the check itself introduced; the repository's own gates found them, and they were fixed before the run:
System.lineSeparator()in generator source. The first version of the check put a"\n"literal inKotlinSyntaxCheck.ktandSystem.lineSeparator()inGeneratedFileWriter.java, so the Java and Kotlin ratchet tests failed. Fixed by joining failures with"; "on one line and normalising Kotlin text withStringUtilRt.convertLineSeparators.metaobjects-codegen-kotlinnow depends onkotlin-compiler-embeddable1.9.24 for the PSI parser. Maven's nearest-wins mediation let that jar override the newer compiler kctfork bundles incodegen-kotlin-exposed1x-checkandintegration-tests-kotlin, givingNoSuchMethodError: setJvmDefaultStableand failed compiles of generated Kotlin. Fixed with<exclusions>on the codegen-kotlin dependency in those two test modules.C#, Java and Kotlin
gen/verifydriven liveIn scratch projects built from this branch, an owned (ejected) generator was edited to append an unclosed class to what it emits, then the real commands were run:
dotnet meta gen(ownedentity)ERR_GEN_SYNTAX: generated C# does not parse, so none of these files were written: shop/Customer.g.cs (generator "entity-generator") line 22:33: } expected.dotnet meta verify --codegenmvn metaobjects:generate(ownednames)generated/java/shop/CustomerNames.java35:26mvn metaobjects:generate(owned Kotlinentity)generated/kotlin/shop/Customer.kt37:26mvn metaobjects:verifyafter a clean generateThat run found two defects, which the test step fixed in this PR:
metaobjects:verifynamed a broken file by its temporary capture path instead of its project path, andKotlinSyntaxCheckdisposed its PSI environment in a JVM shutdown hook, which printed aNoClassDefFoundErrorstack trace after every Maven run because the plugin's class realm was already closed. Re-run on the final head: both goals name the project paths, and no stack trace appears on a failing or a clean run. (Anamescopy made by a realmvn metaobjects:ejectgenerated cleanly, so theERR_WRITER_LEADING_WHITESPACEnote under Test below did not reproduce.)no-mistakes: one run.
Validation
Risk Assessment
✅ Low: All four intent items are implemented and the round-1 fix round (candidate CHANGELOG in the PyPI, Maven and Cargo candidates, a fail-closed JRE check, narrower removal matching, allowlist and --record removed) checks out against the current code. I found no concrete wrong-result path, and I ran no tests, per the review rules.
Testing
Broad regression came from the configured
scripts/ci-local.sh --affected --strict-toolchains, which passed. This turn I drove three scenarios live and all passed. (1) The export-surface gate fails on an unnamed removed name, ignores a name shown only in a fenced code block, and passes when the name is inline with its package. (2) A real Python candidate dry-run runs the gate and produces an sdist and wheel that each carry the candidate CHANGELOG. (3) In a scratch Maven project built from HEAD,metaobjects:generateandmetaobjects:verifyfail withERR_GEN_SYNTAXon an unparseable emitted.javaor.kt. The error names the project path (generated/java/shop/CustomerNames.java) and no shutdown-hook stack trace appears. The unbroken control passes. The C# syntax check was not driven live. The scratch dir and temp files were removed, and the worktree is clean.mvn metaobjects:generateandmetaobjects:verifyin a scratch project with an ejected generator emitting an unparseable.java, then an unparseable.kt, fail with ERR_GEN_SYNTAX…Evidence: Export-surface check: clean, unnamed, fenced-only, inline-named
Evidence: Candidate CHANGELOG function drive
Evidence: Python candidate dry-run: sdist and wheel carry CHANGELOG
Evidence: Maven generate/verify refuse unparseable Java and Kotlin output
Evidence: Maven generate control run
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - 5 warnings resolved, 3 infos
The five warnings were ruled on and fixed in this run; none is open.
docs/features/prerelease.md). Ruling: fix. The trimmed candidate CHANGELOG now ships in the PyPI candidate (sdist, and the wheel asmetaobjects/CHANGELOG.md), in the Maven candidate jars asMETA-INF/CHANGELOG.md(acandidate-changelogprofile inserver/java/pom.xml) and in the Cargo candidate crates (aCHANGELOG.mdbeside each crate manifest). The docs lines that said those candidates do not carry it were updated.JavaSyntaxCheck.java). Ruling: fail closed. With no system Java compiler,genandverifynow fail withERR_GEN_SYNTAXand a message naming the missing JDK. There is no skip and no opt-out flag.JavaSyntaxCheckTestcovers it.scripts/check-export-surface.mjs). Ruling: narrow it. A removed name counts as named only when an upgrade bullet names that identifier together with its package or module, the same narrowing the JVM and C# path uses, and fenced code blocks never count. The false-pass cases from the finding (a name shown only in a fenced block, a common name in another module's bullet) are tests inscripts/test-check-export-surface.mjs, and the README's "What names a removal" was updated.scripts/export-surface/allowlist.json). Ruling: remove. The allowlist file and its logic are gone, so every removed public name has to be in the upgrade list.--recordmode (scripts/check-export-surface.mjs). Ruling: remove. The mode and its README paragraph are gone; baselines are recorded only from what the registries published, byrecord-published.mjs.Infos:
kotlin-compiler-embeddablefor every adopter, through its dependency on codegen-kotlin. Not changed in this PR: the parser loads only when a.ktfile is checked, so a Java-only build never loads it. The download is real, and the upgrade note does not mention it yet.CANDIDATE_LOG_HEADER, and the export-surface gate definitions moved belowgate_metamodel_version()inscripts/ci-local.sh.Found later, by running C#, Java and Kotlin
genandverifyfor real against broken owned generators, and fixed in the test step of this run:mvn metaobjects:verifynamed a file that did not parse by its temporary capture path instead of its project path, and its message said "nothing was written". It now names the project path (generated/java/shop/CustomerNames.java), and the message is true for both goals. AGeneratedFileWriterTestcase covers it.KotlinSyntaxCheckfreed its parser in a JVM shutdown hook, which ran after Maven had closed the plugin's class realm and printed aNoClassDefFoundErrorstack trace after every Maven run. The hook is removed; re-run on the final head, no trace appears on a failing or a clean run.server/java/codegen-base/src/main/java/com/metaobjects/generator/util/JavaSyntaxCheck.java- Intent criterion 2 (gen/verify syntax check for C#, Java, Kotlin) not driven live. Only focused JUnit ran. Needs a live gen/verify run on a corrupted emitted file.node scripts/check-export-surface.mjs --port ts: 0 removals since 1.3.0scripts/ci-local.sh --affected --strict-toolchainsscripts/ci-local.sh --affected --strict-toolchains (baseline, passed, not re-run)node scripts/check-export-surface.mjs --port ts (clean run)node scripts/check-export-surface.mjs --port ts with a fake removed name injected into scripts/export-surface/baseline/ts.json (exit 1), then git checkout restorenode scripts/test-check-export-surface.mjsnode -e candidateChangelog on real CHANGELOG.mdmvn -o -pl codegen-base -am test -Dtest=JavaSyntaxCheckTest,GeneratedFileWriterTest🔧 Fix applied.
1 info (did not reproduce from a real
mvn metaobjects:eject; see "driven live" above):namesgenerator (mvn metaobjects:eject -Dnames=names -Dport=java) failedgeneratewith ERR_WRITER_LEADING_WHITESPACE in the scratch run, because its copy usedw.line(" * GENERATED ...")where the in-tree source usesw.commentLine(...). It was not investigated as a cause:server/java/codegen-springis unchanged by this change, and the in-tree source differs from the ejected copy. Separate from the change under validation.mvn metaobjects:generateandmetaobjects:verifyin a scratch project with an ejected generator emitting an unparseable.java, then an unparseable.kt, fail with ERR_GEN_SYNTAX…scripts/ci-local.sh --affected --strict-toolchainsBaseline:scripts/ci-local.sh --affected --strict-toolchainsalready ran and passed at the target commit; it was not re-run (no source or test files changed this turn).node scripts/check-export-surface.mjs --port tson the clean tree, then with an injected removed name in the baseline: unnamed fails, named only in a fenced block still fails, named inline with its package passes (baseline and fragment restored afterwards)node $E/candidate-changelog-drive.mjs(callscandidateChangelogon the real CHANGELOG.md) andnode scripts/test-prerelease-version.mjsbun run prerelease:publish --only python --dry-run --iter 1with dummy loopback registry env: ran the export-surface gate, built the real sdist and wheel, and checked both carry the candidate CHANGELOGScratch Maven project: installed codegen-base, codegen-kotlin and maven-plugin from HEAD into a scratch local repo, ejected thenamesgenerator, ranmvn metaobjects:generateandmetaobjects:verifyclean, then with an emitted.javaand an emitted.ktbroken✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.